package fichiers;

import espace_physique.*;
import java.awt.Component;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.*;


public class MyDefaultListCellRender implements ListCellRenderer{
    
    private ListCellRenderer next;
    private static ImageIcon iconElement;
    private static JFileChooser jf=new JFileChooser();
    
    public MyDefaultListCellRender(ListCellRenderer next) {
        
        this.next=next;
        
    }
    
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        
        Element e=RacineDossier.getRacine().getElement((String)value);
        File f=e.getFichierCourant();
        if(f!=null){
        iconElement=(ImageIcon) jf.getFileSystemView().getSystemIcon(f);
        }
        JLabel c=(JLabel)next.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
        c.setIcon(iconElement);
        c.setText(f.getAbsolutePath());
        return c;
    }
    
}
